{% extends "base.html" %}
{% block title %}Edit{% end %}

{% block head %}
{% end %}
{% block body %}
{% import tornado.escape %}
<div class="container">
    <div class="row">
        <div class="span10">
            <form action="" method="post">
                <label>title</label>
                <input name="title" type="text" value="{{ escape(recipe.title) }}">
                <label>pic_url</label>
                {% module UploadModule(ptype='cover', pic_id=recipe.pic_url.split('=')[1]) %}
                <label>intro</label>
                <input name="intro" type="text" value="{{ escape(recipe.intro) }}">
                <label>material</label>

                {% for ing,unit in tornado.escape.json_decode(recipe.material) %}
                <div class="cr-ing-rows">
                    <span class="cr-ing"><input type="text" maxlength="20" name="ing" class="cr-ing-input g-border-hover" id="ing1" value="{{ing}}"></span>
                    <span class="cr-unit"><input name="unit" maxlength="20" type="text" class="cr-unit-input g-border-hover" id="unit1" value="{{unit}}"></span>
                </div>
                {% end %}

                <a href="javascript:add_new_line('ing');void(0);" class="cr-add cr-add-ing">+ 增加一行</a>
                <label>detail</label>

                {% for desc,pic_id in tornado.escape.json_decode(recipe.detail) %}
                <div class="cr-steps">
                    <div class="cr-upload-text">
                        <textarea name="step">{{ desc }}</textarea>
                    </div>
                    {% module UploadModule(ptype='steps', pic_id=pic_id) %}
                    <br class="c">
                </div>
                {% end %}
                
                <a href="javascript:add_new_line('steps','{{ hash_id }}');void(0);" class="cr-add cr-add-steps">+ 增加一行</a>
                <label>tips</label>
                <input name="tips" type="text" value="{{ escape(recipe.tips) }}">
                <button type="submit">Submit</button>
            </form>
        </div>
    </div>
</div>
{% end %}
